package com.car.rental.order.controller;

import com.car.rental.common.core.response.ResponseResult;
import com.car.rental.order.dto.RentalExtensionDTO;
import com.car.rental.order.dto.EarlyReturnDTO;
import com.car.rental.order.service.RentalPeriodService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/rental")
@RequiredArgsConstructor
public class RentalPeriodController {

    private final RentalPeriodService rentalPeriodService;

    @PostMapping("/extend")
    public ResponseResult<Void> extendRental(
            @RequestHeader("userId") Long userId,
            @RequestBody @Valid RentalExtensionDTO extensionDTO) {
        return rentalPeriodService.extendRental(userId, extensionDTO);
    }

    @PostMapping("/early-return")
    public ResponseResult<Void> earlyReturn(
            @RequestHeader("userId") Long userId,
            @RequestBody @Valid EarlyReturnDTO returnDTO) {
        return rentalPeriodService.earlyReturn(userId, returnDTO);
    }

    @GetMapping("/overtime/{orderNo}")
    public ResponseResult<Boolean> checkOvertime(@PathVariable String orderNo) {
        return rentalPeriodService.checkOvertime(orderNo);
    }
} 